<template>
  <div class="header">
    <div class="header-c">
      <!--      返回-->
      <div v-if="backable" class="back">
        <svg
          class="back"
          height="16"
          width="16"
          xmlns="http://www.w3.org/2000/svg"
        >
          <path
            d="M6.36 7.922l4.564 4.44-1.172 1.26L4 7.872l.162-.162-.01-.01L9.892 2l1.22 1.23L6.36 7.922z"
            fill="#A0ACBF"
          ></path>
        </svg>
      </div>
      <!--      表头-->
      <div class="left-title">
        <div class="logo-set">
          <slot name="logo">
            <img class="cover"
              src=""
            />
          </slot>
        </div>
        <h1 class="title-set">
          <slot name="formName"></slot>
        </h1>
      </div>

      <!--      用户头像以及姓名-->
      <div v-if="showUser" class="drop-down">
        <div class="user-message">
          <a>
            <img
              src="https://avatar.qwps.cn/avatar/V1BTXzE2MDIwODE3NTQ="
              class="avatar-title"
              @click="show"
            />
          </a>
          <p class="user-name">test</p>
        </div>
        <div v-show="isShow" class="dropdown--content popover">
          <div class="avatar-popover">
            <div class="nickname">test</div>
            <ul class="function-list">
              <li class="item">个人中心</li>
              <li class="item">常用信息管理</li>
              <li class="item">退出账号</li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "header-com",
  props:["backable","showUser"],
  data() {
    return {
      isShow: false,  //是否展示
    };
  },
  methods: {
/**
  * @description: 点击后展示用户其他信息
  */
    show() {
      this.isShow = !this.isShow;
    },
  },
};
</script>

<style lang="scss" scoped>

svg:not(:root) {
  overflow: hidden;
}

.header {
  position: relative;
  background-color: #fff;
  border-bottom: 1px solid #e9e9e9;
  .header-c {
    display: flex;
    height: 56px;
    max-width: 1180px;
    align-items: center;
    padding: 0 16px;
    .back {
      width: 16px;
      height: 16px;
      margin: 0 14px 0 -2px;
    }
    .left-title {
      line-height: 25px;
      display: -ms-flexbox;
      display: flex;
      -ms-flex-align: center;
      align-items: center;
      -ms-flex-pack: center;
      justify-content: center;
      .logo-set {
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 8px;
        width: 30px;
        height: 30px;
        .cover {
          height: 30px;
          width: 30px;
        }
      }
      .title-set {
        font-size: 18px;
        font-weight: 500;
        color: #3c414b;
        margin: 0.67em 0;
      }
    }
    .drop-down {
      position: absolute;
      right: 20px;
      .user-message {
        display: flex;
        align-items: center;
        .avatar-title {
          width: 28px;
          height: 28px;
          margin-left: 24px;
          border-radius: 50%;
          position: relative;
          cursor: pointer;
        }
        .user-name {
          margin: 0 0 0 0.5em;
          font-size: medium;
          font-weight: bold;
        }
      }
      .dropdown--content {
        position: absolute;
        z-index: 999;
      }
      .popover {
        top: 42px;
        left: -18px;
      }
      .avatar-popover {
        padding: 12px;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        background: white;
        -webkit-box-shadow: 0 2px 12px 0 rgba(56, 56, 56, 0.2);
        box-shadow: 0 2px 12px 0 rgba(56, 56, 56, 0.2);
        border-radius: 2px;
        border: 1px solid #d3d3d3;
        .nickname {
          padding: 0 0 16px 0;
          margin: 0 10px 4px 10px;
          font-size: 14px;
          color: #3d4757;
          line-height: 14px;
          font-weight: 600;
          text-align: left;
          border-bottom: 1px solid #e2e6ed;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        .function-list {
          padding: 0;
          .item {
            font-size: 12px;
            line-height: 30px;
            color: #3d4757;
            white-space: nowrap;
            cursor: pointer;
            margin-top: 4px;
            list-style: none;
            padding: 0 10px;
          }
        }
      }
    }
  }
}

</style>
